from global_values import gg
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

class my1(QWidget):
    def __init__(self):
        super().__init__()        
    def closeEvent(self,e):
        a.quit()

class my5(QWidget):
    def __init__(self,ty):
        super().__init__()        
        self.ty = ty
        self.setWindowFlags(Qt.WindowStaysOnTopHint|Qt.FramelessWindowHint|Qt.ToolTip)
        self.setAttribute(Qt.WA_TranslucentBackground)        
        t2 = QTimer(self)
        t2.timeout.connect(self.ont)
        t2.start(100)
        self.show()
        self.x = 0
        self.y = 0
        self.st = 0

    def paintEvent(self,e):                 
        p = QPainter(self) 
        pen = QPen()
        pen.setWidth(7)
        pen.setColor(QColor(255,255,255))
        p.setPen(pen)
        p.drawLine(0,0,0,gg.y-6)
        p.drawLine(0,gg.y+6,0,768)
        pen.setWidth(5)
        pen.setColor(QColor(0,0,0))
        p.setPen(pen)
        p.drawLine(0,0,0,gg.y-6)
        p.drawLine(0,gg.y+6,0,768)
        print('draw')
    
    def deal_chg(self):
        tt = gg.statusL[self.ty]
        ts = self.status
        if not tt[0]:
            if ts[0]:
                self.hide()
            return
        self.setGeometry(tt[1],tt[2],40,40)
        if not ts[0]:
            self.show()        

    def ont(self):
        if gg.status==0:
            self.hide()
            return
        if self.isHidden():
            self.show()

        if self.x!=gg.x or self.y!=gg.y:
            self.setGeometry(gg.x,0,10,768)
            self.update()
        self.x = gg.x
        self.y = gg.y

import threading
from test import testa
t = threading.Thread(target=testa)
t.daemon = True
t.start()
a = QApplication([])  

w = my5(0)
w2 = my1()
w2.show()
a.exec_()